using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping
{
	public class PatientPassIdMap : EntityTypeConfiguration<PatientPassId>
	{
		public PatientPassIdMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.CodeValue)
				.HasMaxLength(50);
				
			this.Property(t => t.IssuedMe)
				.HasMaxLength(50);
				
			this.Property(t => t.IssuedAt)
				.HasMaxLength(50);
				
			this.Property(t => t.IssuedBy)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("PatientPassIds");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.PatientId).HasColumnName("PatientId");
			this.Property(t => t.PatientPassTypeId).HasColumnName("PatientPassTypeId");
			this.Property(t => t.CodeValue).HasColumnName("CodeValue");
			this.Property(t => t.IssuedMe).HasColumnName("IssuedMe");
			this.Property(t => t.IssueDate).HasColumnName("IssueDate");
			this.Property(t => t.ExpiryDate).HasColumnName("ExpiryDate");
			this.Property(t => t.IssuedAt).HasColumnName("IssuedAt");
			this.Property(t => t.IssuedBy).HasColumnName("IssuedBy");
			this.Property(t => t.IsForeigner).HasColumnName("IsForeigner");
			this.Property(t => t.Nationality).HasColumnName("Nationality");

			// Relationships
			this.HasOptional(t => t.Patient)
				.WithMany(t => t.PatientPassIds)
				.HasForeignKey(d => d.PatientId);
				
		}
	}
}

